package edu.calpoly.csc.coursebook.business.beans;

import java.util.HashMap;

import edu.calpoly.csc.coursebook.web.CourseBookController;
import edu.calpoly.csc.coursebook.web.FacebookController;

/****
 * A bean that has more explicit accessors than just a normal map. It also has 
 * the functionality of a normal HashMap if that's what you want. Intended to 
 * be used in the return of <code>FacebookController</code> and 
 * <code>CourseBookController</code>
 *  
 * @author bestrada
 * @see FacebookController
 * @see CourseBookController
 */
public class CourseBookDataModel extends HashMap<String,Object>
{
   public static final String FIRST_NAME = "firstName";
   public static final String LAST_NAME = "lastName";
   public static final String COURSES = "courses";
   
   private boolean _hasFacebookInfo = false;
   
   public void setHasFacebookInfo(boolean b) { this._hasFacebookInfo = b; }
   public boolean getHasFacebookInfo() { return this._hasFacebookInfo; }
   
   public void setFirstName(String name)
   {
      super.put(CourseBookDataModel.FIRST_NAME, name);
   }
   public String getFirstName()
   {
      Object obj = super.get(CourseBookDataModel.FIRST_NAME);
      return null != obj && obj instanceof String ?
	    (String) obj :
	    "first";
   }
   
   public void setLastName(String name)
   {
      super.put(CourseBookDataModel.LAST_NAME, name);
   }
   
   public String getLastName(String name)
   {
      Object obj = super.get(CourseBookDataModel.LAST_NAME);
      return null != obj && obj instanceof String ?
	    (String) obj :
	    "last";
   }
}
